from pydantic import BaseModel, Field
from typing import List, Optional

class BaseBuckling(BaseModel):
    order_id: Optional[int] = Field(0)
    goods_id: Optional[int] = Field(0)
    sku_id: Optional[int] = Field(0)
    user_id: Optional[int] = Field(0)
    nums: Optional[int] = Field(0)
    direction: Optional[int] = Field(0)
    add_uid: Optional[int] = Field(0)
    space_id: Optional[int] = Field(0)
    use_nums: Optional[int] = Field(0)
    last_nums: Optional[int] = Field(0)
    price: float = Field(0.00)
    todo_id: Optional[int] = Field(0)
    over_date: Optional[str] = Field(None)
    group_id: Optional[int] = Field(0)
class BucklingCreate(BaseBuckling):
    ...
class BucklingUpdate(BaseBuckling):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class BaseBucklingTodo(BaseModel):
    order_id: Optional[int] = Field(0)
    user_id: Optional[int] = Field(0)
    goods_id: Optional[int] = Field(0)
    sku_id: Optional[int] = Field(0)
    project_id: Optional[int] = Field(0)
    type: Optional[int] = Field(0)
    status: Optional[int] = Field(0)
    price: Optional[int] = Field(0)
    nums: Optional[int] = Field(0)
    order_goods_id: Optional[int] = Field(0)
    start_date: Optional[str] = Field(None)
    space_id: Optional[int] = Field(0)
class BucklingSelect(BaseModel):
    id: Optional[int] = Field(0)
    selected_ids: Optional[list] = None
    add_uid: Optional[int] = Field(0)
class BucklingTodoCreate(BaseBucklingTodo):
    ...
class BucklingTodoUpdate(BaseBucklingTodo):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class BaseBucklingDetail(BaseModel):
    buckling_id: Optional[int] = Field(0)
    nums: Optional[int] = Field(0)
    cases_id: Optional[int] = Field(0)
    buckling_price: float = Field(0.00)
class BucklingDetailCreate(BaseBucklingDetail):
    ...
class BucklingDetailUpdate(BaseBucklingDetail):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class BaseBucklingGroup(BaseModel):
    type: Optional[int] = Field(1)
    todo_id: Optional[int] = Field(0)
    group_id: Optional[int] = Field(0)
    group_name: Optional[str] = Field(None)
    group_type: Optional[int] = Field(0)
    use_times: Optional[int] = Field(0)
    last_times: Optional[int] = Field(0)
    times: Optional[int] = Field(0)
    over_date: Optional[str] = Field(None)


class BucklingGroupCreate(BaseBucklingGroup):
    ...
class BucklingGroupUpdate(BaseBucklingGroup):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class BaseBucklingGive(BaseModel):
    order_id: Optional[int] = Field(0)
    order_goods_id: Optional[int] = Field(0)
    buckling_todo_id: Optional[int] = Field(0)
    new_customer_id: Optional[int] = Field(0)
    giver_customer_id: Optional[int] = Field(0)
    add_uid: Optional[int] = Field(0)

class BucklingGiveCreate(BaseBucklingGive):
    ...
class BucklingGiveUpdate(BaseBucklingGive):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})


class BaseCases(BaseModel):
    user_id: Optional[int] = Field(0)
    add_uid: Optional[int] = Field(0)
    space_id: Optional[int] = Field(0)
    desc: Optional[str] = Field("")
    files:Optional[list] = Field(None)
    designer_ids: Optional[list] = Field(None)
    buckling_data: Optional[list] = Field(None)
    buckling_consumables: Optional[list] = Field(None)
    e_sign:Optional[str] = Field(None)
    other_form:Optional[list] = Field(None)
    before_pic:Optional[list] = Field(None)
    after_pic:Optional[list] = Field(None)
class CasesCreate(BaseCases):
    ...
class CasesUpdate(BaseCases):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class PayCreate(BaseModel):
    id: Optional[int] = Field(0)
    user_id: Optional[int] = Field(0)
    type:int = 1 ##1点单类型2商城3储值
    sku: Optional[list] = None
    address_id: Optional[int] = Field(0)
    is_deposit: int = Field(0)
    coupons: Optional[list] = None
    remark: Optional[str] = Field(None)


class BaseSchedulingRules(BaseModel):
    label: Optional[str] = Field("")
    start: Optional[str] = Field("")
    end: Optional[str] = Field("")
    color: Optional[str] = Field("")


class SchedulingRulesCreate(BaseSchedulingRules):
    ...

class SchedulingRulesUpdate(BaseSchedulingRules):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class BaseSchedulingDates(BaseModel):
    rules_id: Optional[int] = Field(0)
    designer_id: Optional[int] = Field(0)
    start: Optional[str] = Field("")
    end: Optional[str] = Field("")
    date: Optional[str] = Field("")
    space_id: Optional[int] = Field(0)


class SchedulingDatesCreate(BaseSchedulingDates):
    ...

class SchedulingDatesUpdate(BaseSchedulingDates):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class BaseConsumables(BaseModel):
    name: Optional[str] = Field("")
    guige: Optional[str] = Field("")
    danwei: Optional[str] = Field("")
    order: Optional[int] = Field(0)
    type: Optional[int] = Field(1)

class ConsumablesCreate(BaseConsumables):
    ...

class ConsumablesUpdate(BaseConsumables):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class BaseConsumablesUse(BaseModel):
    consumables_id: Optional[int] = Field(0)
    nums: Optional[float] = Field(0.00)
    user_id: Optional[int] = Field(0)
    # buckling_id: Optional[int] = Field(0)
    # buckling_detail_id: Optional[int] = Field(0)
    cases_id: Optional[int] = Field(0)

class ConsumablesUseCreate(BaseConsumablesUse):
    ...

class ConsumablesUseUpdate(BaseConsumablesUse):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class BaseUserLog(BaseModel):
    user_id: Optional[int] = Field(0)
    data: Optional[str] = Field("")

class UserLogCreate(BaseUserLog):
    ...

class UserLogUpdate(BaseUserLog):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class BasePerformancePercentage(BaseModel):
    order_id: Optional[int] = Field(0)
    goods_id: Optional[int] = Field(0)
    sku_id: Optional[int] = Field(0)
    customer_id: Optional[int] = Field(0)
    user_id: Optional[int] = Field(0)
    space_id: Optional[int] = Field(0)
    price: Optional[float] = Field(0.00)
    buckling_id: Optional[int] = Field(0)
    status: Optional[int] = Field(0)


class PerformancePercentageCreate(BasePerformancePercentage):
    ...

class PerformancePercentageUpdate(BasePerformancePercentage):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})